<template>
  <div class="child">
    <h2>我是Child</h2>
    <h4>我的玩具：{{toy}}</h4>
    <button @click="handleClick">把玩具给父</button>
    <button @click.stop="$emit('send-computer',computer)">把电脑给父</button>
    <button @click="handleClick3">解绑我身上的send-computer</button>
  </div>
</template>

<script>
  export default {
    name:'Child',
    data() {
      return {
        toy:'奥特曼',
        computer:'联想'
      }
    },
    methods: {
      handleClick(){
        // 触发Child组件实例(vc)身上的send-toy事件
        this.$emit('send-toy',this.toy)
      },
      /* handleClick2(){
        // 触发Child组件实例(vc)身上的send-computer事件
        this.$emit('send-computer',this.computer)
      }, */
      handleClick3(){
        //解绑一个
        // this.$off('send-computer') 

        //解绑多个
        // this.$off(['send-computer','send-toy']) 

        //解绑所有
        this.$off() 
      }
    },
  }
</script>

<style>
  .child {
    background-color: skyblue;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    padding: 20px;
  }
</style>